import click
import os
import logging
import logging.config
from logic import handle,handle_v1



@click.group()
@click.option('--logging-config', default=os.path.join(os.path.dirname(__file__), "logging.conf"),
              help="logging config file for built-in python logging module", show_default=True)
def run(**kwargs):
    logging.config.fileConfig(kwargs['logging_config'])

@run.command()
def miniworld1(**kwargs):
    '''计算历年 wikipedia 小世界'''
    # from miniworld import main
    # print("start")
    # logging.info("start")
    handle.my_logic_level()

    
# @run.command()
# def miniworld2(**kwargs):
#     '''计算历年 wikipedia 小世界'''
#     # from miniworld import main
#     # print("start")
#     # logging.info("start")
#     handle.subject_small_world_connect("linksin_lv2_node_v5_newDB_xueshu_new_noLiterature")


@run.command()
@click.option('--lv', default=2, help="wiki-level",type=click.INT, show_default=True)
@click.option('--year', default=2004, help="start-year",type=click.INT, show_default=True)
def miniworld2(**kwargs):
    if kwargs['lv'] == 2:
        handle.subject_small_world_connect("2", kwargs['year'])
    elif kwargs['lv'] == 3:
        handle.subject_small_world_connect("3", kwargs['year'])


@run.command()
@click.option('--lv', default=2, help="wiki-level",type=click.INT, show_default=True)
@click.option('--year', default=2004, help="start-year",type=click.INT, show_default=True)
def xueshu(**kwargs):
    if kwargs['lv'] == 2:
        handle.xueshu_small_world_recon("2", kwargs['year'])
    elif kwargs['lv'] == 3:
        handle.xueshu_small_world_recon("3", kwargs['year'])

@run.command()
@click.option('--lv', default=2, help="wiki-level",type=click.INT, show_default=True)
@click.option('--year', default=2004, help="start-year",type=click.INT, show_default=True)
def xueshu3(**kwargs):
    if kwargs['lv'] == 2:
        handle_v1.xueshu_small_world_recon("2", kwargs['year'])
    elif kwargs['lv'] == 3:
        handle_v1.xueshu_small_world_recon("3", kwargs['year'])

@run.command()
@click.option('--lv', default=2, help="wiki-level",type=click.INT, show_default=True)
@click.option('--year', default=2004, help="start-year",type=click.INT, show_default=True)
def xueshu4(**kwargs):
    if kwargs['lv'] == 2:
        handle_v1.xueshu_small_world_connect("2", kwargs['year'])
    elif kwargs['lv'] == 3:
        handle_v1.xueshu_small_world_connect("3", kwargs['year'])


@run.command()
@click.option('--lv', default=2, help="wiki-level",type=click.INT, show_default=True)
@click.option('--year', default=2004, help="start-year",type=click.INT, show_default=True)
def xueshu2(**kwargs):
    if kwargs['lv'] == 2:
        handle.xueshu_small_world_connect("2", kwargs['year'])
    elif kwargs['lv'] == 3:
        handle.xueshu_small_world_connect("3", kwargs['year'])

@run.command()
@click.option('--lv', default=2, help="wiki-level",type=click.INT, show_default=True)
@click.option('--year', default=2004, help="start-year",type=click.INT, show_default=True)
def miniworld3(**kwargs):
    if kwargs['lv'] == 2:
        handle.subject_small_world_recon("2", kwargs['year'])
    elif kwargs['lv'] == 3:
        handle.subject_small_world_recon("3", kwargs['year'])

if __name__ == '__main__':
    run()
